<?php
require_once "../class/fenajax.class.php";

$f = newFen(__FILE__,"Espace adhérent",0);

$f->displayHeader();

echo "<div class=\"center\">".BMInfo(ucfirst(utf8_encode(strftime("%A %d %B %Y"))),false)."</div>";
?>
<script type='text/javascript'>
function log(){	
		$.ajax({ 
		   type: "POST",
		   url: "../dyn/login.php", 
		   data: "login="+$("#login").val()+"&pass="+$("#pass").val(), 
		   success: function(msg){ 
				if(msg == 1)
				{
					document.location.reload(true);	
				}
				if(msg == 0)
				{
					$("#div_erreur").css({ display: "block" });
				}
		   }
		});
	};
</script>

<?php
$valid = true;
?>

<?php


// Tentative de connexion
if (isset($_SESSION['connect'])){
	
	// Réussite
	if ($_SESSION['connect']) {		
		if (isset($_SESSION['statut'])) {
			if ($_SESSION['statut'] == 0) {
				echo "Veuillez attendre la validation  de l'administrateur";
			}
			if ($_SESSION['statut'] == 1) {
				header("location:contributeur.php");
			}
			else if ($_SESSION['statut'] == 2) {
				header("location:adherent.php");
			}
			else if ($_SESSION['statut'] == 3) {
				header("location:animateur.php");
			}
			else if ($_SESSION['statut'] == 4) {
				header("location:admin.php");
			}
		}
	}

}else {
	
	echo "<div id=\"div_erreur\" class=\"message ui-widget ui-corner-all ui-state-error\" style=\"display: none\">
				<span class=\"ui-icon ui-icon-alert\"></span>
				<span class=\"text\" id=\"erreur\">Echec de la connexion</span>
			</div>
	";
	
	echo '<section class="main">';
	echo '<form name="connexionForm" id="connexionForm" class="form-1" >
		<p class="field">';
		echo '<input id="login" type="text" title="Login/mot de passe incorect" name="login" placeholder="Pseudo" " >
		<i class="icon-user icon-large"></i>
		</p>
		<p class="field">
		<input id="pass" type="password" title="Login/mot de passe incorect" name="pass" placeholder="Mot de passe" ">
		<i class="icon-lock icon-large"></i>
		</p>';
	echo '<p class="submit">
	<input type="button" class="buttonConnexion" onclick="log()" >
	</p>
	</form>
	<p>Vous n\'avez pas de compte ? <a href="inscription.php">Cliquez ici </a>pour un créer un.</p>
	</section>';
	
	
}

$f->displayFooter();

?>










